<?php
require_once '../conf/config.php.inc';
require_once SYBMAS_LIB_PATH.'/liblogin.php.inc';
session_set_cookie_params(SYBMAS_MAX_IDLE_TIME,CONTEXT_NAME,'',false,true);
session_start();
if(array_key_exists('sybmas_requested_url',$_COOKIE)){
	$url=$_COOKIE['sybmas_requested_url'];
	setcookie("sybmas_requested_url",'',time()-3600);
}else{
	$url=CONTEXT_NAME;
}

$username=$_POST['sybmas_username'];
$password=$_POST['sybmas_password'];


if(iniciar_sesion($username,$password)){
	$redirect_to="Location: $url";
}else{
	$redirect_to="Location:".LOGIN_ERROR_PAGE;
}

header($redirect_to);
?>